{{>header}}
<header>
    <div class="nav">
        <div class="logo">
            <h2><a class="bk" href="/">Bookmarkus</a></h2>
        </div>
        <div class="menu">
            <a class="m" href="/profil"><b>{{user.user}} 😸</b></a>
            <a class="m" href="/baca">belum dibaca</a>
            <a class="m" href="/t">test</a>
            <a class="spesial" href="/input">Input</a>
            <a class="m" href="/logout">Logout</a>
        </div>
    </div>
</header>

<main>
    <div id="content">
      <div class="kiri">
            {{#if key}}
            <p class="byTags">Browse bookmarks by tags: <b>{{key}}</b> menemukan <b>{{bookmark.totalDocs}}</b> hasil.</p>
            {{/if}}
            {{#if q}}
            <p class="byTags">Hasil pencarian dengan keyword:  <b>{{q}}</b> menemukan <b>{{bookmark.totalDocs}}</b> hasil.</p>
            {{/if}}
            {{#if error}}
            <p class="byTags">{{error}}</p>
            {{/if}}
              
            {{#if_eq user.role "superuser"}}
            {{#each bookmark.docs}}
            <div class="items {{#if_eq nanti "on"}}nanti{{/if_eq}}">
                <h4><a href="{{url}}" target="_blank">{{judul}}</a></h4>
                <p class="uraian">{{uraian}}</p>
                  {{#each tags}}
                <span class="tags">
                    <a href="/tags/{{this}}" class="tag">#{{this}}</a>
                </span>
                {{/each}}
                <div class="d_aksi">
                  <div class="aksi"> 
                    <span><a href="/edit/{{_id}}" class="edit">edit</a></span>
                    <span><a href="/hapus/{{_id}}" class="hapus">hapus</a></span>
                  </div>
                  <div class="baca">
                    {{#if_eq nanti "on"}}
                       <a href="/baca/{{_id}}?ref=baca">√ sudah baca</a>
                       {{ origin }}
                    {{/if_eq}}
                  </div>
                </div>
            </div>
            {{/each}}{{else}}
            {{#each bookmark.docs}}
            <div class="items">
                <h4><a href="{{url}}" target="_blank">{{judul}}</a></h4>
                <p class="uraian">{{uraian}}</p>
                {{#each tags}}
                <span class="tags">
                    <a href="/tags/{{this}}" class="tag">#{{this}}</a>
                </span>
                {{/each}}
            </div>
            {{/each}}
            {{/if_eq}}
            
            <div class="navi">
                <div class="balik">
                    {{#if bookmark.hasPrevPage}}
                    <a href="?page={{bookmark.prevPage}}{{#if q}}&q={{q}}{{/if}}">⇐ Sebelumnya</a>
                    {{/if}}
                </div>
            
                <div class="lanjut">
                    {{#if bookmark.hasNextPage}}
                    <a href="?page={{bookmark.nextPage}}{{#if q}}&q={{q}}{{/if}}">Selanjutnya ⇒</a>
                    {{/if}}
                </div>
            </div>

      </div>
      <div class="kanan"> 
          <div class="mencari">
              <form action="/cari" method="get">
                <input class="cari" type="text" name="q"><input type="submit" class="login__but" value="Cari">
               </form>
          </div>

        <div class="tagslist">
        </div>
      </div>
    </div>
</main>
{{>footer}}
